/* ===================================================================
   Apple Design System CSS Framework
   基于Apple Human Interface Guidelines的设计系统
   版本：v1.0
   创建时间：2025-07-20
=================================================================== */

/* CSS Variables - Apple Design Tokens */
:root {
    /* Apple Color Palette */
    --apple-blue: #007AFF;
    --apple-blue-light: #5AC8FA;
    --apple-blue-dark: #0051D5;
    --apple-green: #34C759;
    --apple-orange: #FF9500;
    --apple-red: #FF3B30;
    --apple-yellow: #FFCC00;
    --apple-purple: #AF52DE;
    --apple-pink: #FF2D92;
    --apple-teal: #5AC8FA;

    /* System Colors */
    --system-background: #FFFFFF;
    --system-background-secondary: #F2F2F7;
    --system-background-tertiary: #FFFFFF;
    --system-grouped-background: #F2F2F7;
    --system-grouped-background-secondary: #FFFFFF;
    --system-grouped-background-tertiary: #F2F2F7;

    /* Label Colors */
    --label-primary: #000000;
    --label-secondary: rgba(60, 60, 67, 0.6);
    --label-tertiary: rgba(60, 60, 67, 0.3);
    --label-quaternary: rgba(60, 60, 67, 0.18);

    /* Separator Colors */
    --separator-opaque: #C6C6C8;
    --separator-non-opaque: rgba(60, 60, 67, 0.29);

    /* Fill Colors */
    --fill-primary: rgba(120, 120, 128, 0.2);
    --fill-secondary: rgba(120, 120, 128, 0.16);
    --fill-tertiary: rgba(120, 120, 128, 0.12);
    --fill-quaternary: rgba(120, 120, 128, 0.08);

    /* Typography */
    --font-family-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
    --font-family-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;

    /* Font Sizes - Apple Scale */
    --font-size-large-title: 34px;
    --font-size-title-1: 28px;
    --font-size-title-2: 22px;
    --font-size-title-3: 20px;
    --font-size-headline: 17px;
    --font-size-body: 17px;
    --font-size-callout: 16px;
    --font-size-subhead: 15px;
    --font-size-footnote: 13px;
    --font-size-caption-1: 12px;
    --font-size-caption-2: 11px;

    /* Font Weights */
    --font-weight-ultralight: 100;
    --font-weight-thin: 200;
    --font-weight-light: 300;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-heavy: 800;
    --font-weight-black: 900;

    /* Spacing Scale */
    --spacing-1: 4px;
    --spacing-2: 8px;
    --spacing-3: 12px;
    --spacing-4: 16px;
    --spacing-5: 20px;
    --spacing-6: 24px;
    --spacing-8: 32px;
    --spacing-10: 40px;
    --spacing-12: 48px;
    --spacing-16: 64px;
    --spacing-20: 80px;

    /* Border Radius */
    --radius-small: 6px;
    --radius-medium: 8px;
    --radius-large: 12px;
    --radius-xlarge: 16px;
    --radius-full: 50%;

    /* Shadows */
    --shadow-small: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-large: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xlarge: 0 20px 25px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --transition-fast: 0.15s ease-out;
    --transition-normal: 0.2s ease-out;
    --transition-slow: 0.3s ease-out;

    /* Z-Index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-header: 1035;
    --z-sidebar: 1025;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --system-background: #000000;
        --system-background-secondary: #1C1C1E;
        --system-background-tertiary: #2C2C2E;
        --system-grouped-background: #000000;
        --system-grouped-background-secondary: #1C1C1E;
        --system-grouped-background-tertiary: #2C2C2E;

        --label-primary: #FFFFFF;
        --label-secondary: rgba(235, 235, 245, 0.6);
        --label-tertiary: rgba(235, 235, 245, 0.3);
        --label-quaternary: rgba(235, 235, 245, 0.16);

        --separator-opaque: #38383A;
        --separator-non-opaque: rgba(84, 84, 88, 0.6);

        --fill-primary: rgba(120, 120, 128, 0.36);
        --fill-secondary: rgba(120, 120, 128, 0.32);
        --fill-tertiary: rgba(120, 120, 128, 0.24);
        --fill-quaternary: rgba(120, 120, 128, 0.18);
    }
}

/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family-system);
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-regular);
    line-height: 1.47;
    color: var(--label-primary);
    background-color: var(--system-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
.large-title {
    font-size: var(--font-size-large-title);
    font-weight: var(--font-weight-regular);
    line-height: 1.12;
    letter-spacing: 0.374px;
}

.title-1 {
    font-size: var(--font-size-title-1);
    font-weight: var(--font-weight-regular);
    line-height: 1.14;
    letter-spacing: 0.364px;
}

.title-2 {
    font-size: var(--font-size-title-2);
    font-weight: var(--font-weight-regular);
    line-height: 1.18;
    letter-spacing: 0.35px;
}

.title-3 {
    font-size: var(--font-size-title-3);
    font-weight: var(--font-weight-regular);
    line-height: 1.2;
    letter-spacing: 0.38px;
}

.headline {
    font-size: var(--font-size-headline);
    font-weight: var(--font-weight-semibold);
    line-height: 1.24;
    letter-spacing: -0.408px;
}

.body {
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-regular);
    line-height: 1.29;
    letter-spacing: -0.408px;
}

.callout {
    font-size: var(--font-size-callout);
    font-weight: var(--font-weight-regular);
    line-height: 1.25;
    letter-spacing: -0.32px;
}

.subhead {
    font-size: var(--font-size-subhead);
    font-weight: var(--font-weight-regular);
    line-height: 1.27;
    letter-spacing: -0.24px;
}

.footnote {
    font-size: var(--font-size-footnote);
    font-weight: var(--font-weight-regular);
    line-height: 1.23;
    letter-spacing: -0.08px;
}

.caption-1 {
    font-size: var(--font-size-caption-1);
    font-weight: var(--font-weight-regular);
    line-height: 1.33;
    letter-spacing: 0px;
}

.caption-2 {
    font-size: var(--font-size-caption-2);
    font-weight: var(--font-weight-regular);
    line-height: 1.36;
    letter-spacing: 0.066px;
}

/* Button System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2);
    padding: var(--spacing-2) var(--spacing-4);
    font-size: var(--font-size-callout);
    font-weight: var(--font-weight-medium);
    line-height: 1.25;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
    -webkit-appearance: none;
    appearance: none;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.25);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Primary Button */
.btn-primary {
    background-color: var(--apple-blue);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--apple-blue-dark);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
    background-color: var(--fill-secondary);
    color: var(--label-primary);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--fill-primary);
    transform: translateY(-1px);
}

/* Outline Button */
.btn-outline {
    background-color: transparent;
    color: var(--apple-blue);
    border: 1px solid var(--separator-opaque);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--fill-quaternary);
    border-color: var(--apple-blue);
}

/* Destructive Button */
.btn-destructive {
    background-color: var(--apple-red);
    color: white;
}

.btn-destructive:hover:not(:disabled) {
    background-color: #D70015;
    transform: translateY(-1px);
}

/* Button Sizes */
.btn-small {
    padding: var(--spacing-1) var(--spacing-3);
    font-size: var(--font-size-subhead);
}

.btn-large {
    padding: var(--spacing-3) var(--spacing-6);
    font-size: var(--font-size-headline);
}

/* Form Elements */
.form-group {
    margin-bottom: var(--spacing-4);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-1);
    font-size: var(--font-size-subhead);
    font-weight: var(--font-weight-medium);
    color: var(--label-primary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--spacing-3);
    font-size: var(--font-size-body);
    font-family: var(--font-family-system);
    color: var(--label-primary);
    background-color: var(--system-background-secondary);
    border: 1px solid var(--separator-opaque);
    border-radius: var(--radius-medium);
    transition: all var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.25);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--label-tertiary);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Card System */
.card {
    background-color: var(--system-background);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-small);
    overflow: hidden;
    transition: box-shadow var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-medium);
}

.card-header {
    padding: var(--spacing-4);
    border-bottom: 1px solid var(--separator-non-opaque);
    background-color: var(--system-background-secondary);
}

.card-body {
    padding: var(--spacing-4);
}

.card-footer {
    padding: var(--spacing-4);
    border-top: 1px solid var(--separator-non-opaque);
    background-color: var(--system-background-secondary);
}

/* Alert System */
.alert {
    padding: var(--spacing-3) var(--spacing-4);
    border-radius: var(--radius-medium);
    margin-bottom: var(--spacing-4);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-2);
}

.alert-info {
    background-color: rgba(0, 122, 255, 0.1);
    color: var(--apple-blue-dark);
    border: 1px solid rgba(0, 122, 255, 0.2);
}

.alert-success {
    background-color: rgba(52, 199, 89, 0.1);
    color: #248A3D;
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.alert-warning {
    background-color: rgba(255, 149, 0, 0.1);
    color: #B25000;
    border: 1px solid rgba(255, 149, 0, 0.2);
}

.alert-error {
    background-color: rgba(255, 59, 48, 0.1);
    color: #D70015;
    border: 1px solid rgba(255, 59, 48, 0.2);
}

/* Badge System */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-1) var(--spacing-2);
    font-size: var(--font-size-caption-1);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary {
    background-color: var(--apple-blue);
    color: white;
}

.badge-secondary {
    background-color: var(--fill-secondary);
    color: var(--label-primary);
}

.badge-success {
    background-color: var(--apple-green);
    color: white;
}

.badge-warning {
    background-color: var(--apple-orange);
    color: white;
}

.badge-danger {
    background-color: var(--apple-red);
    color: white;
}

/* Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-backdrop);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background-color: var(--system-background);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-xlarge);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: all var(--transition-normal);
}

.modal-overlay.show .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: var(--spacing-4);
    border-bottom: 1px solid var(--separator-non-opaque);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--font-size-headline);
    font-weight: var(--font-weight-semibold);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--font-size-title-2);
    color: var(--label-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background-color: var(--fill-quaternary);
}

.modal-body {
    padding: var(--spacing-4);
    overflow-y: auto;
}

.modal-footer {
    padding: var(--spacing-4);
    border-top: 1px solid var(--separator-non-opaque);
    display: flex;
    gap: var(--spacing-3);
    justify-content: flex-end;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.fw-light { font-weight: var(--font-weight-light); }
.fw-normal { font-weight: var(--font-weight-regular); }
.fw-medium { font-weight: var(--font-weight-medium); }
.fw-semibold { font-weight: var(--font-weight-semibold); }
.fw-bold { font-weight: var(--font-weight-bold); }

.text-primary { color: var(--label-primary); }
.text-secondary { color: var(--label-secondary); }
.text-tertiary { color: var(--label-tertiary); }
.text-blue { color: var(--apple-blue); }
.text-green { color: var(--apple-green); }
.text-orange { color: var(--apple-orange); }
.text-red { color: var(--apple-red); }

.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }

.flex-column { flex-direction: column; }
.flex-row { flex-direction: row; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.align-start { align-items: flex-start; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }

.gap-1 { gap: var(--spacing-1); }
.gap-2 { gap: var(--spacing-2); }
.gap-3 { gap: var(--spacing-3); }
.gap-4 { gap: var(--spacing-4); }

.m-0 { margin: 0; }
.m-1 { margin: var(--spacing-1); }
.m-2 { margin: var(--spacing-2); }
.m-3 { margin: var(--spacing-3); }
.m-4 { margin: var(--spacing-4); }

.p-0 { padding: 0; }
.p-1 { padding: var(--spacing-1); }
.p-2 { padding: var(--spacing-2); }
.p-3 { padding: var(--spacing-3); }
.p-4 { padding: var(--spacing-4); }

.rounded { border-radius: var(--radius-medium); }
.rounded-large { border-radius: var(--radius-large); }
.rounded-full { border-radius: var(--radius-full); }

.shadow-small { box-shadow: var(--shadow-small); }
.shadow-medium { box-shadow: var(--shadow-medium); }
.shadow-large { box-shadow: var(--shadow-large); }

/* Navigation System */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--system-background);
    border-bottom: 1px solid var(--separator-non-opaque);
    z-index: var(--z-header);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 var(--spacing-4);
    max-width: 100%;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-6);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    font-size: var(--font-size-headline);
    font-weight: var(--font-weight-semibold);
    color: var(--label-primary);
}

.nav-brand i {
    color: var(--apple-blue);
    font-size: 20px;
}

.nav-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    font-size: var(--font-size-subhead);
    color: var(--label-secondary);
}

.breadcrumb-item.active {
    color: var(--label-primary);
    font-weight: var(--font-weight-medium);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
}

.nav-button {
    position: relative;
    background: none;
    border: none;
    padding: var(--spacing-2);
    border-radius: var(--radius-medium);
    color: var(--label-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-button:hover {
    background-color: var(--fill-quaternary);
    color: var(--label-primary);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background-color: var(--apple-red);
    color: white;
    font-size: 10px;
    font-weight: var(--font-weight-semibold);
    padding: 2px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    padding: var(--spacing-2) var(--spacing-3);
    border-radius: var(--radius-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-menu:hover {
    background-color: var(--fill-quaternary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
}

.user-name {
    font-size: var(--font-size-subhead);
    font-weight: var(--font-weight-medium);
    color: var(--label-primary);
}

/* Sidebar System */
.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 240px;
    background-color: var(--system-background-secondary);
    border-right: 1px solid var(--separator-non-opaque);
    z-index: var(--z-sidebar);
    overflow-y: auto;
}

.sidebar-content {
    padding: var(--spacing-4);
}

.sidebar-section {
    margin-bottom: var(--spacing-6);
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-title {
    font-size: var(--font-size-caption-1);
    font-weight: var(--font-weight-semibold);
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-3);
    padding: 0 var(--spacing-3);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    margin-bottom: var(--spacing-1);
}

.menu-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3);
    color: var(--label-secondary);
    text-decoration: none;
    border-radius: var(--radius-medium);
    transition: all var(--transition-fast);
    font-size: var(--font-size-subhead);
}

.menu-link:hover {
    background-color: var(--fill-quaternary);
    color: var(--label-primary);
}

.menu-item.active .menu-link {
    background-color: var(--apple-blue);
    color: white;
}

.menu-link i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mobile-hidden { display: none; }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .nav-breadcrumb {
        display: none;
    }
    
    .btn {
        padding: var(--spacing-3) var(--spacing-4);
    }
    
    .modal {
        margin: var(--spacing-4);
        max-width: calc(100vw - 32px);
    }
    
    .card {
        border-radius: var(--radius-medium);
    }
}

@media (max-width: 480px) {
    :root {
        --font-size-large-title: 28px;
        --font-size-title-1: 24px;
        --font-size-title-2: 20px;
    }
    
    .btn {
        font-size: var(--font-size-subhead);
    }
}